package com.hellowx_ssm.controller;

import com.hellowx_ssm.entity.User;
import com.hellowx_ssm.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

/**
 * Created by IntelliJ IDEA.
 *
 * @author MagicMushroom
 * @date 2021/6/23
 */
@Controller
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

//    @Autowired
//    public void setUserService(UserService userService) {
//        this.userService = userService;
//    }

    @RequestMapping("/login")
    public ModelAndView login(User user){
        System.out.println(user);
        ModelAndView mv  = new ModelAndView();
        User login = userService.login(user);
        if (login!=null){
            mv.setViewName("ok");
        }else {
            mv.setViewName("login");
        }
        return mv;
    }

}
